package com.xunge.controller;

import com.xunge.pojo.StudentOption;
import com.xunge.pojo.JobOption;
import com.xunge.pojo.Result;
import com.xunge.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/report")
public class ReportController {

    @Autowired
    private ReportService reportService;

    @GetMapping("/empJobData")
    public Result getEmpJobData(){
        log.info("统计员工信息");
        JobOption jo = reportService.getEmpJobData();
        return Result.success(jo);
    }
    @GetMapping("/empGenderData")
    public Result getEmpGenderData(){
        log.info("统计性别信息");
        List<Map<String,Object>> genderData = reportService.getEmpGenderData();
        return Result.success(genderData);
    }
    @GetMapping("/studentCountData")
    public Result getStudentCountData(){
        log.info("统计学生信息");
        StudentOption so = reportService.countStudentData();
        return Result.success(so);
    }

    @GetMapping("/studentDegreeData")
    public Result getStudentDegreeData(){
        log.info("统计学历信息");
        List<Map<String,Object>> degreeData = reportService.getStudentDegreeData();
        return Result.success(degreeData);
    }

    @GetMapping("/studentGenderData")
    public Result getStudentGenderData(){
        log.info("统计学员性别信息");
        List<Map<String,Object>> genderData = reportService.getStudentGenderData();
        return Result.success(genderData);
    }

    @GetMapping("/gradeUsualData")
    public Result getGradeUsualData(@RequestParam(required = false) String semester){
        log.info("统计平时成绩分布，学期：{}", semester);
        List<Map<String,Object>> gradeData = reportService.getGradeUsualData(semester);
        return Result.success(gradeData);
    }

    @GetMapping("/gradeMidtermData")
    public Result getGradeMidtermData(@RequestParam(required = false) String semester){
        log.info("统计期中成绩分布，学期：{}", semester);
        List<Map<String,Object>> gradeData = reportService.getGradeMidtermData(semester);
        return Result.success(gradeData);
    }

    @GetMapping("/gradeFinalData")
    public Result getGradeFinalData(@RequestParam(required = false) String semester){
        log.info("统计期末成绩分布，学期：{}", semester);
        List<Map<String,Object>> gradeData = reportService.getGradeFinalData(semester);
        return Result.success(gradeData);
    }

    @GetMapping("/gradeTotalData")
    public Result getGradeTotalData(@RequestParam(required = false) String semester){
        log.info("统计总评成绩分布，学期：{}", semester);
        List<Map<String,Object>> gradeData = reportService.getGradeTotalData(semester);
        return Result.success(gradeData);
    }

    @GetMapping("/semesters")
    public Result getSemesters(){
        log.info("获取所有学期");
        List<String> semesters = reportService.getSemesters();
        return Result.success(semesters);
    }
}
